<include file="header" />
<body>
<div class="wraper">
    <div class="header">
        <a href="/base/center/center/account_id/{BEESCRM:$account_id}" class="iconfont icon-zuo back"></a>
        <div class="title text-center font-16">个人中心</div>
    </div>
    <div <if condition="$card['status'] eq 3">class="main-card main-card2"<else />class="main-card"</if> >
        <div class="user flex">
            <div class="logo logo2">
                <if condition="$account_id eq 2 or $account_id eq 38">
                    <img src="/assets/base/onecard/images/logo.png" alt="">
                <else />
                    <img src="/assets/base/onecard/images/logo_hd.png" alt="">
                </if>
            </div>
            <div>
                <p>{BEESCRM:$card['user_name']}</p>
                <p class="font-12 Student_ID">{BEESCRM:$card['number']}</p>
                <p class="font-12">状态：<if condition="$card['status'] eq 3">挂失中<elseif condition="$card['status'] eq 2" />已解绑<elseif condition="$card['status'] eq 1" />已绑定<else/>未绑定</if></p>
            </div>
        </div>
        <div class="text-right font-16 ">
            <div>余额 <span>{BEESCRM:$card['balance']}</span> 元</div>
        </div>
        <div class="bg-logo">
            <if condition="$account_id eq 2 or $account_id eq 38">
                <img src="/assets/base/onecard/images/logo.png" alt="">
            <else />
                <img src="/assets/base/onecard/images/logo_hd.png" alt="">
            </if>
        </div>
    </div>
    <div class="classify">
        <if condition = "$account_id eq 2 or $account_id eq 25 or $account_id eq 4 or $account_id eq 60">
        <a <if condition="$card['status'] eq 3">class="list flex-between gray gray3" <else />class="list flex-between gray" href="/index.php?g=base&m=OneCard&a=pay&one_card_id={BEESCRM:$one_card_id}" </if> >
            <div class="iconfont icon-logo icon-chongzhi"></div>
            <div class="right flex-between">
                <div>充值</div>
                <div class="iconfont  icon-jiantou"></div>
            </div>
        </a>
        </if>
        <if condition = "$account_id eq 2 or $account_id eq 25 or $account_id eq 4 or $account_id eq 60">
            <a href="/base/OneCard/payrecord/one_card_id/{BEESCRM:$one_card_id}" class="list flex-between gray">
                <div class="iconfont icon-logo icon-chongdianjilu font-20"></div>
                <div class="right flex-between">
                    <div>充值记录</div>
                    <div class="iconfont  icon-jiantou"></div>
                </div>
            </a>
        </if>
        <if condition = "$account_id eq 38 or $account_id eq 25 or $account_id eq 4 or $account_id eq 60">
            <a href="/base/OneCard/orderlog/one_card_id/{BEESCRM:$one_card_id}" class="list flex-between gray">
                <div class="iconfont icon-logo icon-chongdianjilu font-20"></div>
                <div class="right flex-between">
                    <div>消费记录</div>
                    <div class="iconfont  icon-jiantou"></div>
                </div>
            </a>
        </if>
        <a href="/base/OneCard/flow/one_card_id/{BEESCRM:$one_card_id}" class="list flex-between gray">
            <div class="iconfont icon-logo icon-chongdianjilu font-20"></div>
            <div class="right flex-between">
                <div>交易流水</div>
                <div class="iconfont  icon-jiantou"></div>
            </div>
        </a>
        <a href="javascript:void(0);" <if condition="$card['status'] eq 3"> class="list flex-between gray gray3"<else /> class="list flex-between gray js_unbundle"</if> >
            <div class="iconfont icon-logo icon-bangqiajiebangwenti font-20"></div>
            <div class="right flex-between">
                <div>解绑</div>
                <div class="iconfont  icon-jiantou"></div>
            </div>
        </a>
        <if condition="$card['status'] neq 3">
            <a href="#" class="list flex-between gray js_loss">
                <div class="iconfont icon-logo icon-bangqiajiebangwenti font-20"></div>
                <div class="right flex-between">
                    <div>挂失</div>
                    <div class="iconfont  icon-jiantou"></div>
                </div>
            </a>
        </if>
    </div>
    <div class="pop-box hide" id="unbind_box">
        <div class="pop-hint text-center">
            <div class="top"></div>
            <div class="pop-title font-16">
                请输入验证密码
            </div>
            <div class="password">
                <input type="text" id="last_six_bit" class="text-center" placeholder="密码为身份证后六位">
            </div>
            <a href="#" class="btn text-center btn-ok" id="btn_ok_unbind">确定</a>
            <p class="font-12 gray"><span class="red">注：</span>您正在对一卡通进行解绑操作</p>
            <div class="close iconfont icon-chacha1">
            </div>
        </div>
    </div>

    <div class="pop-box hide" id="loss_box">
        <div class="pop-hint text-center">
            <div class="top"></div>
            <div class="pop-title font-16">
                请输入交易密码
            </div>
            <div class="password">
                <input type="text" id="password" class="text-center" placeholder="请输入一卡通交易密码">
            </div>
            <a href="#" class="btn text-center btn-ok" id="btn_ok_loss">确定</a>
            <p class="font-12 gray"><span class="red">注：</span>您正在对一卡通进行挂失操作</p>
            <div class="close iconfont icon-chacha1 close_loss">
            </div>
        </div>
    </div>

</div>
</body>
<include file="commonJs" />
<script>
    var height=$(window).height();
    $('.wraper').css('minHeight',height);

//    $(function () {
//        var Student_ID=$('.Student_ID').text();
//        var lenght=Student_ID.length;
//        var lenght2=lenght-8;
//        var text1=Student_ID.substr(0,4);
//        var text2=Student_ID.substring(lenght-4,lenght);
//        var value='';
//        for(var i=1;i<=lenght2;i++){
//            value+='*';
//        }
//        $(".Student_ID").html(text1+value+text2);
//    });

    //解绑操作
    $('.js_unbundle').click(function () {
        $("#last_six_bit").val('');
        $('#unbind_box').removeClass('hide');
    });
    //挂失操作
    $('.js_loss').click(function () {
        $("#password").val('');
        $('#loss_box').removeClass('hide');
    });
    //解绑窗口关闭
    $('.close').click(function () {
        $('#unbind_box').addClass('hide');
    });
    //挂失窗口关闭
    $('.close_loss').click(function () {
        $('#loss_box').addClass('hide');
    });
    $('#btn_ok_unbind').click(function () {
        var last_six_bit = $("#last_six_bit").val();
        if(!last_six_bit ){
            fm.alert("请输入身份证后六位");
            return false;
        }
        if(!/^[0-9A-Za-z]{6}$/.test(last_six_bit)){
            fm.alert("身份证后六位格式错误");
            return false;
        }
        var url = "{BEESCRM::U('/base/OneCard/doUnBland',array('one_card_id'=>$one_card_id))}";

        $.ajax({
            url:url,
            type:"POST",
            dataType:"json",
            data:{last_six_bit:last_six_bit},
            success:function (res) {
                if(res.status == 'S'){
                    fm.alert("解绑成功");
                    $('#unbind_box').addClass('hide');
                    window.sessionStorage.setItem("local_url","/base/OneCard/nocard/one_card_id/"+ one_card_id);
                    setTimeout(redirect, 2000);
                } else {
                    fm.alert(res.message);
                }
            }
        });

        function redirect() {
            window.location.href = window.sessionStorage.getItem("local_url");
            window.sessionStorage.setItem("local_url",null);
        }
    });
    $('#btn_ok_loss').click(function () {
        var password = $("#password").val();
        if(!password ){
            fm.alert("请输入交易密码");
            return false;
        }
        var url = "{BEESCRM::U('/base/OneCard/doLoss',array('one_card_id'=>$one_card_id))}";
        $.ajax({
            url:url,
            type:"POST",
            dataType:"json",
            data:{password:password},
            success:function (res) {
                if(res.status == 'S'){
                    fm.alert(res.message);
                    $('#loss_box').addClass('hide');
                    window.sessionStorage.setItem("local_url","/base/OneCard/personalCenter/one_card_id/"+ one_card_id);
                    setTimeout(redirect, 2000);
                } else {
                    fm.alert(res.message);
                }
            }
        });

        function redirect() {
            window.location.href = window.sessionStorage.getItem("local_url");
            window.sessionStorage.setItem("local_url",null);
        }
    });
</script>
</html>